package cn.jiyun.function.controller;

import cn.jiyun.Result.Result;
import cn.jiyun.function.service.OrdersService;
import cn.jiyun.pojo.Orders;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("orders")
@Slf4j
public class OrdersController {
    @Autowired OrdersService ordersService;

    @PostMapping("/findPage")
    public Result findPage(@RequestParam(defaultValue = "1", name = "pageNum") Integer PageNum,
                           @RequestParam(defaultValue = "10", name = "pageSize") Integer PageSize,
                           @RequestBody Orders orders){
        log.info("orders: {}",orders);
        PageInfo<Orders> page = ordersService.findPage(PageNum, PageSize,orders);
        return Result.ok(page);
    }
    @PostMapping("findxq")
    public Result findxq( Integer id){

        Orders order = ordersService.findxq(id);
        return Result.ok(order);
    }

}
